package com.example.controller;

import com.example.common.Result;
import com.example.entity.Medications;
import com.example.entity.User;
import com.example.service.MedicationService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/medication")
public class MedicationController {
    @Resource
    private MedicationService medicationService;

    @PostMapping("/add")
    private Result addMedication(@RequestBody List<Medications> medicationsList){
        return medicationService.addMedication(medicationsList);
    }

    @PostMapping("/list")
    private Result listMedication(@RequestBody User user){
        return medicationService.listMedication(user);
    }

    @PostMapping("/listAll")
    private Result listAll(){
        return medicationService.listAll();
    }

    @PostMapping("/delete")
    private Result deleteMedication(@RequestBody Medications medications){
        return medicationService.deleteMedication(medications);
    }

    @PostMapping("/update")
    private Result updateMedication(@RequestBody Medications medications){
        return medicationService.updateMedication(medications);
    }
}
